Propagate custom cfg directives to rustdoc, fixes #1980
authorGleb Kozyrev <gleb@gkoz.com>
Sat, 10 Oct 2015 14:39:19 +0000 (17:39 +0300)
committerGleb Kozyrev <gleb@gkoz.com>
Sun, 11 Oct 2015 17:57:33 +0000 (20:57 +0300)
src/cargo/ops/cargo_rustc/mod.rs

index fab000d179e618994251155e1b1be318d7107e92..8461f4837830bb7cdec09bf773f14533ba9a442e 100644 (file)
@@ -398,11 +398,17 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult<Work> {
     }
 
     let name = unit.pkg.name().to_string();
-    let desc = rustdoc.to_string();
+    let build_state = cx.build_state.clone();
+    let key = (unit.pkg.package_id().clone(), unit.kind);
     let exec_engine = cx.exec_engine.clone();
 
     Ok(Work::new(move |desc_tx| {
-        desc_tx.send(desc).unwrap();
+        if let Some(output) = build_state.outputs.lock().unwrap().get(&key) {
+            for cfg in output.cfgs.iter() {
+                rustdoc.arg("--cfg").arg(cfg);
+            }
+        }
+        desc_tx.send(rustdoc.to_string()).unwrap();
         exec_engine.exec(rustdoc).chain_error(|| {
             human(format!("Could not document `{}`.", name))
         })